package com.hzhr.iot.login.controller;

import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.core.util.HzhrIotUtil;
import com.hzhr.iot.login.controller.base.BaseController;
import com.hzhr.iot.login.model.userCard.UserCardGetModel;
import com.hzhr.iot.login.service.UserCardService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@Api(tags = "user-card", description = "用户名片相关服务")
@RestController
@RequestMapping(value = "")
public class UserCardController extends BaseController {
    @Autowired
    UserCardService userService;

    //region /user-cards/{token} GET
    //region swagger响应码 : getUserCard
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : getUserCard
    @ApiOperation(value="查询用户名片", notes="查询用户名片  \n简介 : 所有用户名片  \n步骤 :  \n1. 查询用户名片 : 根据路径参数“令牌”查询用户卡片“用户卡片_1”；(√)  \n2. 返回信息 : 根据“用户卡片_1”生成并返回“用户名片模型(查询)”；(√)  \n",produces = "application/json")
    //endregion
    //region swagger参数 : getUserCard
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "path"),
    })
    //endregion
    //region 请求 : getUserCard
    @RequestMapping(value = "/user-cards/{token}", method = RequestMethod.GET)
    //endregion
    public ResponseEntity<UserCardGetModel> getUserCard(@PathVariable("token") String token,
                                                        @RequestParam @ApiIgnore Map<String, Object> query) throws ServiceException {
        Map<String, String> header = initHeader();
        header = HzhrIotUtil.initGlobalHeader(header);

        UserCardGetModel responseBody = userService.getUserCard(header, token, query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
}































































































































































































